package book;

public class BookList {
    private Book[] books;//书架--放很多书所以用数组//Book类型的数组 没有初始化默认为null
    private static final int DEFAULT_SIZE=4;//初始化后的长度
    private int usedSize;//默认为0，代表有效书籍的个数
    public BookList(){
        this.books=new Book[DEFAULT_SIZE];
        books[0]=new Book("我胆小如鼠","余华",49.9,"中篇小说");
        books[1]=new Book("藏海花","南派三叔",48,"探险寻迷");
        books[2]=new Book("一只特立独行的猪","王小波",35,"杂文集");
        this.usedSize=3;
    }

    //知道现在书架上有多少本书
    public int getUsedSize() {
        return this.usedSize;
    }
    //更改书架上书的数量
    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }
    //得到books数组
    public Book[] getBooks() {
        return books;
    }
    //扩容books数组
    public void setBooks(Book[] books) {
        this.books = books;
    }
    //得到下标为pos的书籍信息
    public Book getBook(int pos){
        return this.books[pos];
    }
    //置空对象，回收内存
    public void setBook(int pos,Book book){
        this.books[pos]=book;
    }
}
